import React from 'react';
import { inject, observer } from 'mobx-react';
import { withRouter } from 'react-router-dom';

import { TabPage } from 'weaver-mobile-page';

import DefaultShare from './DefaultShare';
import MyShare from './MyShare';

import { Tools } from 'weaver-mobile';

const getLabel = Tools.getLabel;

@inject('userCenterStore')
@withRouter
@observer
export default class ShareSet extends React.Component {
  static defaultProps = {
    prefixCls: 'blog-userCenter-shareSet',
  }

  componentDidMount () {
		const { userCenterStore: { userShareSetStore } } = this.props;
    userShareSetStore.initData();
  }

  render() {
    const { prefixCls, userCenterStore: { userShareSetStore } } = this.props;
    const { isLoading, selectedTabIndex, onTabChange } = userShareSetStore;
    const tabs = [
      {title: getLabel(381919,'默认分享')},
      {title: getLabel(33310,'我的分享')},
    ]

    return (
      <div className={prefixCls}>
        <TabPage 
          tabs={tabs}
          tabProps = {{
            page: selectedTabIndex,
            onChange: (tab, index) => onTabChange(index),
          }}
        />
        { selectedTabIndex === 0 && <DefaultShare /> }        
        { selectedTabIndex === 1 && <MyShare /> }
      </div>
    )
  }
}